// Core_UnitTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

class TestClass
{
public:
	TestClass()
		: mX(0)
		, mHeight(0.0f)
	{
	}

	int mX;
	float mHeight;
};

int _tmain(int argc, _TCHAR* argv[])
{
	MOE::Core::ClassMeta intMeta(MOE::Core::BasicType::kInt32, "Int", 0);
	MOE::Core::ClassMeta floatMeta(MOE::Core::BasicType::kFloat32, "Float", 0.0f);

	MOE::Core::ClassMeta testClassMeta("TestClass", sizeof(TestClass));
	assert(testClassMeta.GetSize() == sizeof(TestClass));

	MOE::Core::Type* xFieldType = new MOE::Core::Type(intMeta);
	MOE::Core::Field* xField = new MOE::Core::Field(testClassMeta, "X", *xFieldType, offsetof(TestClass, mX));
	assert(xFieldType->GetTypeSize() == sizeof(MOE::Core::int32));

	MOE::Core::Type* heightFieldType = new MOE::Core::Type(floatMeta);
	MOE::Core::Field* heightField = new MOE::Core::Field(testClassMeta, "Height", *heightFieldType, offsetof(TestClass, mHeight));
	assert(heightFieldType->GetTypeSize() == sizeof(MOE::Core::float32));

	testClassMeta.AddField(xField);
	testClassMeta.AddField(heightField);

	TestClass testObject;

	MOE::Core::BasicTypeHelpers::Write(*xField, 1, &testObject);

	assert(testObject.mX == 1);

	testObject.mX = 2;
	int i;
	xField->ReadValue(&testObject, &i);

	assert(i == 2);

	assert(MOE::Core::BasicTypeHelpers::IsSupportedBasicType<int>::Value);
	assert(!MOE::Core::BasicTypeHelpers::IsSupportedBasicType<TestClass>::Value);

	MOE::Core::tHashValue hash1 = MOE::Core::StringToHash("X");
	std::string xstr("X");
	MOE::Core::tHashValue hash2 = MOE::Core::StringToHash(xstr.c_str());
	assert(hash1 == hash2);

	return 0;
}
